package com.beanbean.mvvmtest.model;

import android.os.Handler;

import com.beanbean.mvvmtest.base.BaseLoadListener;
import com.beanbean.mvvmtest.bean.UserInfo;

import java.util.ArrayList;
import java.util.List;

public class ListModeImpl implements IListModel {
    List<UserInfo> list = new ArrayList<>();
    @Override
    public void loadUserData(int page,final BaseLoadListener<UserInfo> loadListener) {
        if (loadListener != null){
            loadListener.loadStart();
        }
        list.clear();
        UserInfo info;
        for (int i = 0; i < 10; i++) {
            info = new UserInfo("李三",i+(page-1)*10);
            list.add(info);
        }
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if (loadListener != null){
                    loadListener.loadSuccess(list);
                    loadListener.loadComplete();
                }
            }
        }, 2000);

    }
}
